\name{blag}
\alias{blag}
\alias{llag}
\alias{wlag}

%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Functions to create lag values
}
\description{
The function \code{blag()} creates a basis for lag values of x.
The function \code{lag()} creates a list with two components i) a basis matrix and  ii) weights to be used as prior weights in any regression analysis. The function \code{wlag()} is take a "mlags" objects and returns a prior weights vector.  
}
\usage{
blag(x, lag = 1, omit.na = FALSE, no.x = TRUE, value = NA, ...)
llag(x, ...)
wlag(x)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{x}{
For \code{blag()} and \code{llag()} x is the vector for creating lags. For \code{wlag()} x is an \code{mlags} object created by \code{blag()}.   
}
  \item{lag}{
how many lag values are required, that is, the number of columns in the basis matrix (if x is not included, see \code{no.x})
}
  \item{omit.na}{
if true the first "lag" rows of the resulting matrix are omitted
}
  \item{no.x}{
If TRUE only lag values of x are included. if FALSE  x is included as well in the basis matrix as the first column.
 }
  \item{value}{
value : what values should be set in the beginning of the lags columns, by default is set to NA
}
  \item{\dots}{
additional arguments
}
}
\details{
Those three functions are design for helping a user to fit a lag regression by generating appropriate structures.
The function \code{blag()} creates a basis for lag values of x. It assumed  that the time is from the oldest to the newest. That is, the latest observations are the most recent. The function The function \code{wlag()} take a lag basis matrix and creates a vector of weights which can be used as a prior weights for any regression type analysis.  The function \code{lag()} creates a list with the matrix base and the weights.   
}
\value{
The function \code{blag()} returns a "mlags" object (matrix of lag values).
The function \code{llag()} returns a lis with components:
 \item{matrix}{The basis of the lag matrix}
 \item{weights}{The weights vector}
The function \code{wlag()} returns a vector of prior weights
}
\references{
Rigby, R. A. and  Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), 
\emph{Appl. Statist.}, \bold{54}, part 3, pp 507-554.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R.
Accompanying documentation in the current GAMLSS  help files, (see also  \url{http://www.gamlss.com/}).

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.
\emph{Journal of Statistical Software}, Vol. \bold{23}, Issue 7, Dec 2007, \url{http://www.jstatsoft.org/v23/i07}.
}
\author{
Mikis Stasinopoulos <\email{d.stasinopoulos@londonmet.ac.uk}>, Bob Rigby <\email{r.rigby@londonmet.ac.uk}> 
Vlasis Voudouris <\email{v.voudouris@londonmet.ac.uk}>, Majid  Djennad, Paul Eilers.
}


%% ~Make other sections like Warning with \section{Warning }{....} ~

%\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
%}
\examples{
library(stats)
y <- arima.sim(500, model=list(ar=c(.4,.3,.1))) 
X <- blag(y, 5, value=0)
head(X)
w<-wlag(X)
library(gamlss)
m1<-gamlss(y~X, weights=w )
summary(m1)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{regression}
\keyword{ts}
